import 'package:flutter/material.dart';
import 'package:huajianshe_app/base/BaseState.dart';
import 'package:huajianshe_app/common/C.dart';
import 'package:huajianshe_app/common/load_image.dart';

import 'Btn.dart';

class ImageWithBadge extends StatefulWidget {

  String url;
  int num;
  VoidCallback? onPressed;

  ImageWithBadge(this.url, {this.num = 0, this.onPressed});

  @override
  State<StatefulWidget> createState() {
    return _ImageWithBadgeState();
  }
}

class _ImageWithBadgeState extends BaseState<ImageWithBadge> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      child: Stack(
        children: [
          Padding(padding: EdgeInsets.all(10), child: LoadImage(widget.url, width: 23.5, height: 22.5),),
          Positioned(
            child: SizedBox(width: 20, height: 20,
                child: Btn(text: '${widget.num}', radius: 10)
            ),
            right: 0, top: 0,)
        ],
      ),
      onTap: widget.onPressed,
    );
  }
}